package 多线程.CompletableFuture异步编排;



import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadTestAsyn2 {
      //创建线程池
    public static ExecutorService executor = Executors.newFixedThreadPool(10);

     public static void main(String[] args) throws Exception {

         //2、Supply，有返回值
         CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> {
         System.out.println("current thread: " + Thread.currentThread().getId());
         int i = 10 / 2;
         System.out.println("run result: " + i);
         return i;
      }, executor);
         Integer integer = future.get();
         System.out.println(integer);
         System.out.println("main...end..");
     }
}